package com.agan.aganjavaspyder.crawler.un_demo;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.*;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.spider.HtmlBean;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author agan
 * @ClassName StartCtPhone
 * @Description
 * @Date 2020/10/15 9:11 下午
 **/
@Setter
@Getter
@Gecco(matchUrl="http://s.10010.com/SearchApp/chseSearchList/init?keyword={keyword}&wd={wd}",pipelines = {
        "consolePipeline", "UNPhonePipeline" })
public class StartCtPhone implements HtmlBean {

    @Request
    private HttpRequest request;

    @RequestParameter("keyword")
    private String keyword;

    @RequestParameter("wd")
    private String wd;


    @Text
    @HtmlField(cssPath = "#selectOtherList > div.searchResultInfor > label.cOrange")
    private int totalSize;

    @Href
    @HtmlField(cssPath="#goodsList > ul > li.goodsLi > a")
    private List<String> resultText;

    public static void main(String[] args) {
        GeccoEngine.create()
                //Gecco搜索的包路径
                .classpath("com.agan.aganjavaspyder.crawler.un_demo")
                //开始抓取的页面地址
                .seed("http://s.10010.com/SearchApp/chseSearchList/init?keyword=手机&wd=手机")
                //开启几个爬虫线程
                .thread(1)
                .debug(true)
                //单个爬虫每次抓取完一个请求后的间隔时间
                .interval(2000)
                .start();
    }




}
